package com.kly.cashmall.module.repay.presenter;

import com.google.gson.JsonArray;
import com.kly.cashmall.bean.QueryPayResultBean;
import com.kly.cashmall.framework.mvp.BaseViewPresenter;
import com.kly.cashmall.services.Network;
import com.kly.cashmall.services.Params;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;


/**
 * author :
 * date   : 2020/4/7 11:47
 * desc   :
 */
public class RepayResultPresenter extends BaseViewPresenter<RepayResultViewer> {

    public RepayResultPresenter(RepayResultViewer viewer) {
        super(viewer);
    }

    @Override
    public void willDestroy() {

    }

    public void queryPayStatus(JsonArray array,int type) {
        Params params = new Params();
        params.put("billNos", array);
        params.put("type", type);
        rxManager.add(Network.getApi().getQueryRepay(params.buildPostBody()).subscribeOn(Schedulers.io()).observeOn
                (AndroidSchedulers.mainThread()).subscribe(new Consumer<QueryPayResultBean>() {
            @Override
            public void accept(QueryPayResultBean bean) throws Exception {
                if (getViewer() != null) {
                    getViewer().getRepayStatusSuccess(bean);
                }
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
            }
        }));
    }
}
